#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <stdio.h>

//dijkstra

using namespace std;
using PII = pair<int, int>;

const int N = 1010, M = 4e4 + 10, INF = 0x3f3f3f3f;

int n, m, s, t;
int h[N], e[M], ne[M], w[M], idx;
int fo[N];
int dist[N];
int st[N];

void add(int a, int b, int c)
{
    e[idx] = b;
    ne[idx] = h[a];
    w[idx] = c;
    h[a] = idx++;
}

int dijkstra()
{
    memset(dist, 0x3f, sizeof dist);
    memset(st, 0, sizeof st);

    priority_queue<PII, vector<PII>, greater<PII>> que;
    dist[0] = 0;
    que.push({dist[0], 0});

    while (que.size())
    {
        PII temp = que.top();
        que.pop();

        int ver = temp.second, dis = temp.first;

        if (st[ver])
            continue;

        st[ver] = true;

        for (int u = h[ver]; u != -1; u = ne[u])
        {
            int j = e[u];
            if (dist[j] > dis + w[u])
            {
                dist[j] = dis + w[u];
                que.push({dist[j], j});
            }
        }
    }

    if (dist[s] == INF)
    {
        return -1;
    }
    else
    {
        return dist[s];
    }
}

int main()
{
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    
    while (scanf("%d%d%d", &n, &m, &s) != -1)
    {
        memset(h, -1, sizeof h);
        idx = 0;
        for (int i = 0; i < m; i++)
        {
            int a, b, c;
            scanf("%d%d%d", &a, &b, &c);
            add(a, b, c);
        }

        scanf("%d", &t);
        for (int i = 0; i < t; i++)
        {
            scanf("%d", &fo[i]);
            add(0, fo[i], 0);
        }


        int t = dijkstra();

        printf("%d\n", t);
    }

    return 0;
}